# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=maigret
pkgver=main.r46.gb90cdb1
_pyver=3.13
pkgrel=1
epoch=1
pkgdesc='OSINT username checker. Collect a dossier on a person by username from a huge number of sites.'
groups=('blackarch' 'blackarch-social' 'blackarch-recon')
arch=('any')
url='https://github.com/soxoj/maigret'
license=('MIT')
depends=('python' 'python-aiohttp' 'python-aiohttp-socks' 'python-aiodns'
         'python-arabic-reshaper' 'python-async-timeout' 'python-attrs'
         'python-beautifulsoup4' 'python-certifi' 'python-chardet'
         'python-colorama' 'python-dateutil' 'python-future' 'python-idna'
         'python-future-annotations' 'python-html5lib' 'python-jinja'
         'python-lxml' 'python-markupsafe' 'python-mock' 'python-multidict'
         'python-pycountry' 'python-pypdf2' 'python-pysocks' 'python-networkx'
         'python-python-bidi' 'python-requests' 'python-requests-futures'
         'python-six' 'python-socid-extractor' 'python-soupsieve' 'python-stem'
         'python-torrequest' 'python-tqdm' 'python-typing_extensions'
         'python-webencodings' 'python-xhtml2pdf' 'python-xmind' 'python-yarl'
         'python-tokenize-rt' 'python-cloudscraper' 'python-alive-progress')
makedepends=('git' 'python-build' 'python-pip')
source=("git+https://github.com/soxoj/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

build() {
  cd $pkgname

  python -m build --wheel --outdir="$startdir/dist"
}

package() {
  cd $pkgname

  pip install \
    --verbose \
    --disable-pip-version-check \
    --no-warn-script-location \
    --ignore-installed \
    --no-compile \
    --no-deps \
    --root="$pkgdir" \
    --prefix=/usr \
    --no-index \
    --find-links="file://$startdir/dist" \
    $pkgname

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -rf "$pkgdir/usr/lib/python$_pyver/site-packages/utils/" \
    "$pkgdir/usr/lib/python$_pyver/site-packages/tests"
}

